//
//  SearchDeviceListViewController.m
//  jingdongfang
//
//  Created by mac on 16/9/8.
//  Copyright © 2016年 ZhiYu Hao. All rights reserved.
//

#import "SearchDeviceListViewController.h"
#import "TPKeyboardAvoidingTableView.h"
#import "SearchDeviceCell.h"
#import "IGiGalleryAddSlaveUserApi.h"

@interface SearchDeviceListViewController ()<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet TPKeyboardAvoidingTableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArray;

@end

@implementation SearchDeviceListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    self.title = @"搜索结果";
    self.title = NSLocalizedString(@"Search Result", nil);
    [_tableView registerNib:[UINib nibWithNibName:@"SearchDeviceCell" bundle:nil] forCellReuseIdentifier:@"SearchDeviceCell"];
    // Do any additional setup after loading the view from its nib.
}

#pragma mark - UITableViewDelegate UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    SearchDeviceCell *cell =[tableView dequeueReusableCellWithIdentifier:@"SearchDeviceCell"];
    cell.iconImageView.layer.masksToBounds = YES;
    cell.iconImageView.layer.cornerRadius = 25;
    [cell.iconImageView sd_setImageWithURL:[NSURL URLWithString:self.userInfo.image] placeholderImage:[UIImage imageNamed:@"place_head_Icon"]];
    cell.nameLab.text = self.userInfo.nike;
    cell.phonelab.text = self.macId;
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.1f;
}
    
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.1f;
}
    
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    IGiGalleryAddSlaveUserApi *api = [[IGiGalleryAddSlaveUserApi alloc] initWithMacId:self.macId uId:self.userInfo.uid];
    __weak typeof(self) weakSelf = self;
    [api startWithDecodeClass:[IGiGalleryAddSlaveUserResp class] CompletionBlockWithSuccess:^(id responseObject, NSError *error) {
        if (responseObject) {
//            [weakSelf presentMessageTips:@"邀请发送成功"];
            [weakSelf presentMessageTips:NSLocalizedString(@"Invitation Sent Successfully", nil)];
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
